
<include file="App/Home/View/Public/header.html" />
<div id="general-main" role="main">
	<div class="container general-content"> 
		<div class="overview clearfix">
			<div class="pull-left clearfix pull-wid">
				<div class="overview-info pull-left">
					<!-- <p>{$currency['currency_name']}对人民币</p> -->
					<p>{$currency['currency_mark']}/RMB</p>
				</div>
				<div class="overview-trade pull-right deal-count">
					<p>成交量</p>
					<p data-bind="text: ticket().Vol">{$currency_or['all_num']|default=0}</p>
				</div>
				<div class="overview-trade pull-right pull-margrig">
					<p>最低价-最高价</p>
					<p>
						<span data-bind="text: SCS() + ticket().Low">{$currency_or['zuidi']|default=0}</span> -
						<span data-bind="text: SCS() + ticket().High">{$currency_or['zuigao']|default=0}</span>
					</p>
				</div>
				<div class="overview-trade pull-right pull-margrig">
					<p>买一价 / 卖一价</p>
					<p>
						<span class="buy" data-bind="text: SCS() + ticket().Buy">
							{$currency_or['buy_price']|default=0}</span> / <span class="sell"
							data-bind="text: SCS() + ticket().Sell">{$currency_or['sell_price']|default=0}</span>
					</p>
				</div>

				<div class="new pull-right pull-margrig">
					<p>最新价</p>
					<p>
						<span data-bind="text: SCS() + ticket().Last">{$currency_or['new_price']|default=0}</span>
					</p>
				</div>
			</div> 
		</div> 
		<div class="k-wrapper clearfix">
			<div>
				<div class="k-line-list"><a href="#"
						class="btn pro-k active">专业版 K线</a>
					<div class="select-mark">
				</div>
				<iframe src="{:U('Kline/index',['currency_id'=>$currency['currency_id']])}"style="width: 100%; height: 500px"></iframe>
			</div>
		</div>
		<input id="currency_id" type="hidden" value="{$currency['currency_id']}" />
		<div class="assets clearfix assets-overhide">
			<notempty name="session">
				<div class="pull-left assets-detail">
					<div class="btc clearfix">
						<div class="title">我的人民币资产</div>
						<div class="available assets-high">
							可用： <span class="green" data-bind="text:pca().Balance">{$user_currency_money['currency_trade']['num']}</span>
						</div>
						<div class="frozen assets-high">
							冻结： <span class="red" data-bind="text:pca().Locked">{$user_currency_money['currency_trade']['forzen_num']}</span>
						</div>
						<div class="total">
							总计： <span data-bind="text:pca().Amount">{$user_currency_money['currency_trade']['all_num']}</span>
						</div>
						<div class="action">
						</div>
					</div>
					<div class="cny clearfix">
						<div class="title">我的{$currency['currency_mark']}资产</div>
						<div class="available assets-high">
							可用： <span class="green" data-bind="text:sca().Balance">{$user_currency_money['currency']['num']}</span>
						</div>
						<div class="frozen assets-high">
							冻结： <span class="red" data-bind="text:sca().Locked">{$user_currency_money['currency']['forzen_num']}</span>
						</div>
						<div class="total">
							总计： <span data-bind="text:sca().Amount">{$user_currency_money['currency']['num']}</span>
						</div>
						<div class="action">
							<a class="btn" href="{:U('Pay/bpay',['currency_id'=>$currency['currency_id']])}">充币</a>
						</div>
					</div> 
				</div> 
			<else/>
				<div class="pull-left assets-detail">
					<span class="index-myasset"> 我的资产：<a
						href="{:U('Reg/reg')}">注册</a><i>|</i><a
						href="{:U('Index/index')}">登录</a>
					</span>
				</div>
			</notempty>
			<div class="pull-right role panel">
				{$currency['currency_mark']} 交易规则：<br>
				<br>{$currency['detail_url']}
			</div>
		</div>
		<notempty name="session">
		<div data-bind="visible: isShowTradePanel()==&#39;true&#39;"
			class="trade-wrapper clearfix">
			<div class="pull-left clearfix pull-hight">
				<div class="buy panel panel-shad">
					<div class="panel-heading">买入{$currency['currency_mark']}</div>
					<div class="panel-body">
						<form class="form-horizontal">
							<div class="form-group">
								<label class="control-label">最佳买价：</label>
								<div class="form-right">
									<p class="form-control-static">
										<span class="green" data-bind="text: bestPrice">{$sell_record[count($sell_record)-1]['price']|number_format=###,$currency['currency_digit_num']}</span>
										<span class="gray">RMB</span>
									</p>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label" for="buy-price">买入价：</label>
								<div class="form-right">
									<input type="text" class="form-control panel-shad"
										value="{$sell_record[count($sell_record)-1]['price']|number_format=###,$currency['currency_digit_num']}" style="color:#999" name="buyprice" id="coinpricein" onkeyup="vNum(this,{$currency.currency_digit_num});zuidakemai();" onclick="if(value==defaultValue){value='';};if(value=='0'){value='';}" onblur="if(value==''){value='0.000';};aaa()" >
								</div>
							</div>
							<div class="form-group">
								<label class="control-label">最大可买：</label>
								<div class="form-right">
									<p class="form-control-static">
										<span class="maxcoin" id = "coinbuy_aa">{$user_currency_money['currency_trade']['num']/$sell_record[count($sell_record)-1]['price']}</span> <span
											class="gray">{$currency['currency_mark']}</span>
									</p>
								</div>
							</div>
							<!-- <div class="form-group">
								<label class="control-label">买入比例：</label>
								<div class="form-right">
									<div class="form-control-static buy-percent clearfix">
										<div data-bind="slideControl: percent" data-type="buy"
											class="control">
											<div class="round"></div>
											<div class="highlight"></div>
											<div class="background"></div>
										</div>
										<span class="percent"
											data-bind="text: (percent() * 100).toFixed(0) + &#39;%&#39;">0%</span>
									</div>
								</div>
							</div> -->
							<div class="form-group">
								<label class="control-label" for="buy-amount">买入数量：</label>
								<div class="form-right">
									<input type="text" class="form-control panel-shad"
									 name="buynum" id="numberin" onkeyup="vNum(this,{$currency.currency_digit_num});" autocomplete="off" type="text" value="">
								</div>
							</div>
							<div class="form-group">
								<label class="control-label">交易额：</label>
								<div class="form-right">
									<p class="form-control-static">
										<input type="text" class="form-control panel-shad"
										 id="coinin_sumprice" type="text" onkeyup='total_in(this,{$currency.currency_digit_num});' name="total" required="required" disabled="disabled">
									</p>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label">手续费：</label>
								<div class="form-right">
									<p class="form-control-static">
										<span id="feebuy">0.0000</span><span class="gray">（{$currency.currency_buy_fee|default="0.00%"}%）{$currency.currency_mark}</span>
									</p>
								</div>
							</div>
							<div class="form-group" data-bind="visible:isShowPassword()">
								<label class="control-label" for="trade-password">交易密码：</label>
								<div class="form-right">
									<input type="password" class="form-control panel-shad "
										 id="pwdtradein" value="{$Think.session.tradepwd}" >
								</div>
							</div>
							<div class="mark-bos">
								<div class="mark-bos-b">
									<div class="btn btn-buy btn-rad" onclick="buy()">买入</div>
									<div class="mark-buy-text"
										id="trustmsgin"
										style="display: none;"></div>
								</div>
							</div>
						</form>
					</div>
					<!-- /ko -->
					<template id="trade-buy-template"></template>
				</div>
				<div class="sell panel panel-shad">
					<div class="panel-heading">卖出{$currency['currency_mark']}</div>
					<!-- ko component: {
                    name: "trade-sell",
                    params: {type: "buy"}
                } -->
					<div class="panel-body">
						<form class="form-horizontal">
							<div class="form-group">
								<label class="control-label">最佳卖价：</label>
								<div class="form-right">
									<p class="form-control-static">
									
										<span class="green" data-bind="text: bestPrice">{$buy_record[0]['price']|number_format=###,$currency['currency_digit_num']}</span>
										<span class="gray">RMB</span>
										
										
									</p>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label" for="sell-price">卖出价：</label>
								<div class="form-right">
									<input type="text" class="form-control panel-shad"
										 value="{$buy_record[0]['price']|number_format=###,$currency['currency_digit_num']}" style="color:#999;" class="buyinput" id="coinpriceout" onkeyup="vNum2(this,{$currency.currency_digit_num});" onclick="if(value==defaultValue){value='';}" onblur="if(value==''){value='0.000';}">
								</div>
							</div>
							<div class="form-group">
								<label class="control-label">最大可卖：</label>
								<div class="form-right">
									<p class="form-control-static">
										<span  id="coinsale_max" onclick="$('#numberout').val(this.innerHTML)">{$user_currency_money['currency']['num']}</span> 
										<span class="gray">{$currency['currency_mark']}</span>
									</p>
								</div>
							</div>
							<!-- <div class="form-group">
								<label class="control-label">卖出比例：</label>
								<div class="form-right">
									<div class="form-control-static buy-percent clearfix">
										<div data-bind="slideControl: percent" data-type="sell"
											class="control">
											<div class="round"></div>
											<div class="highlight"></div>
											<div class="background"></div>
										</div>
										<span class="percent"
											data-bind="text: (percent() * 100).toFixed(0) + &#39;%&#39;">0%</span>
									</div>
								</div>
							</div> -->
							<div class="form-group">
								<label class="control-label" for="sell-amount">卖出数量：</label>
								<div class="form-right">
									<input type="text" class="form-control panel-shad"
										id="numberout" onkeyup="vNum2(this,{$currency.currency_digit_num});" autocomplete="off" type="text" value="" >
								</div>
							</div>
							<div class="form-group">
								<label class="control-label">交易额：</label>
								<div class="form-right">
									<p class="form-control-static">
										<input type="text" class="form-control panel-shad"
										 id="coinout_sumprice" type="text" onkeyup='total_out(this,{$currency.currency_digit_num})' name="total" required="required" disabled="disabled">
									</p>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label">手续费：</label>
								<div class="form-right">
									<p class="form-control-static">
										<span id="fee">0.0000</span> <span
											class="gray">（{$currency.currency_sell_fee|default="0.00"}% ）{$currency.currency_mark}</span>
									</p>
								</div>
							</div>
							<div class="form-group" data-bind="visible:isShowPassword()">
								<label class="control-label" for="sell-password">交易密码：</label>
								<div class="form-right">
									<input type="password" class="form-control panel-shad "
										id="pwdtradeout" value="{$Think.session.tradepwd}" autocomplete="off">
								</div>
							</div>
							<div class="mark-bos">
								<div class="mark-bos-b">
									<div class="btn btn-sell btn-rad" onclick="sell()">卖出</div>
									<div class="mark-buy-text"
										id="trustmsgout"
										style="display: none;"></div>
								</div>
							</div>
						</form>
					</div>

					<!-- /ko -->
					<template id="trade-sell-template"></template>
				</div>
			</div>
			
			<notempty name="session">
			<div class="pull-right">
				<div class="header">
					<span>我的最近10笔委单</span> <a
						href="{:U('Entrust/manage')}"
						class="pull-right pull-right-allcom">我的委托</a>

				</div>
				<div class="panel list panel-shad">
					<div class="panel-heading">
						<span>委托时间</span> <span>委托类型</span> <span>委托价</span> <span>委托量</span>
						<span>操作</span>
					</div>
					<!-- ko component: "my-order" -->
					<ul class="list-group" data-bind="foreach: orders">
						 <foreach name='user_orders' item='v'>
							<li class="list-group-item {$v.type}" data-bind="css: Type">
								<span class="time" data-bind="text: TimeDisplay">{$v.add_time|date=' H:i:s',###}</span> 
								<span class="type" data-bind="text: TypeName">
									{$v['type']|fomatOrdersType=###}
								</span> 
								<span class="price" data-bind="text: Price">{$v.price|number_format=###,$currency['currency_digit_num']}</span> 
								<span class="amount" data-bind="text: Amount">{$v['num']-$v['trade_num']|number_format=###,2}</span> 
								<span class="total" data-bind="text: Total"  onclick="cexiao({$v.orders_id})">撤销</span>
							</li>
			             </foreach>
					</ul>
					<!-- /ko -->
					<template id="my-order-template"></template>
				</div>
			</div>
			</notempty>
			
		</div>
		
		</notempty>
		<div class="deep-wrapper clearfix">
			<div class="pull-left pull-left-hight">
				<div class="title clearfix">
					<div class="pull-left pull-mag">委托信息</div>
				</div>

				<div class="buy-wrapper pull-left panel panel-bor">
					<div class="panel-heading clearfix">
						<span>买入</span> <span>买入价</span> <span>委单量</span> <span></span>
					</div>
					<!-- ko component: {
                name: "transcation",
                params: {type: "buy"}
            } -->
					<ul class="list-group" data-bind="foreach: transcations">
						<volist name='buy_record' key='k' id='vo'>
							<li class="list-group-item" onclick="buynum(this)" onmouseover="chufa(this)" onmouseout="likai(this)">
								<span class="action">买({$k})</span>
								<span class="price" data-bind="text: price">{$vo.price|formatOrderNum=###}</span> <span
								class="amount" data-bind="text: amount"><eq name="currency.currency_name" value="比特币" >{$vo['num']-$vo['trade_num']|number_format=###,3} <else/> {$vo['num']-$vo['trade_num']|number_format=###,2}</eq></span> 
							</li>
			            </volist>  
					</ul>
					<!-- /ko -->

					<template id="transcation-template"></template>
				</div>
				<div class="sell-wrapper pull-right panel panel-bor">
					<div class="panel-heading clearfix">
						<span>卖出</span> <span>卖出价</span> <span>委单量</span> <span></span>
					</div>
					<ul class="list-group" data-bind="foreach: transcations">
						<volist name='sell_record' key='k' id='vo'>
				            <li class="list-group-item"  onclick="getsell(this)"  onmouseover="chufa1(this)" onmouseout="likai1(this)">
				            <span class="action">卖({$k})</span>
							<span class="price" data-bind="text: price">{$vo.price|formatOrderNum=###}</span> <span
							class="amount" data-bind="text: amount"><eq name="currency.currency_name" value="比特币" > {$vo['num']-$vo['trade_num']|number_format=###,3} <else/>{$vo['num']-$vo['trade_num']|number_format=###,2}</eq></span>  
						</li>
			            </volist>
					</ul>
					<!-- /ko -->
				</div>
			</div>

			<div class="pull-right">
				<ul class="nav nav-tabs">
					<li role="presentation" class="active"><a
						href="#"
						id="new-trade-tab" role="tab" data-toggle="tab"
						aria-controls="new-trade" aria-expanded="true">最新成交</a></li>
					<!-- <li role="presentation"><a data-bind="click:my.refresh()"
						href="#"
						id="my-trade-tab" role="tab" data-toggle="tab"
						aria-controls="my-trade" aria-expanded="false">我的成交</a></li> -->
				</ul>

				<div class="tab-content">
					<div role="tabpanel"
						class="tab-pane fade active in panel panel-shad" id="new-trade"
						aria-labelledby="new-trade-tab">
						<div class="panel-heading ">
							<span>成交时间</span> <span>类型</span> <span class="price">成交价</span>
							<span class="Amount">成交量</span> <span class="value">成交额</span>
						</div>
						<ul class="list-group" data-bind="foreach: latest.orders">
							<volist name='trade' id='vo'>
								<li class="list-group-item {$vo.type}" data-bind="css: Type"><span
								class="time" data-bind="text: TimeDisplay">{$vo.add_time|date=' H:i:s',###}</span> <span
								class="type" data-bind="text: TypeName"><eq name='vo.type' value='sell'>卖出<else/>买入</eq></span> <span
								class="price" data-bind="text: Price">{$vo.num|number_format=###,4}</span> <span
								class="amount" data-bind="text: Amount">{$vo.price|number_format=###,$currency['currency_digit_num']}</span> <span
								class="total" data-bind="text: Total">{$vo['num']*$vo['price']|number_format=###,4}</span></li>
				            </volist>
						</ul>
					</div>

					<div role="tabpanel" class="tab-pane fade" id="my-trade"
						aria-labelledby="my-trade-tab">
						<div class="panel-heading">
							<span>成交时间</span> <span>类型</span> <span class="price">成交价(BTC)</span>
							<span class="Amount">成交量(ETH)</span> <span class="value">成交额(BTC)</span>
						</div>
						<ul class="list-group" data-bind="foreach: my.orders"></ul>
					</div>
				</div>
			</div>
		</div> 
	</div>
</div>

<script>
function aaa(){
var num=$('#coinpricein').val();
var num_p=parseFloat(num);
$('#coinpricein').val(num_p);
}
function numberfomate(num,decimal){
	var f = ''+num;
	var str = f.split('.');
	if(str.length == 1){
		str[1] = '';
	}
	//console.log(str);
	if(str[1].length >= decimal ){
		var flo = str[1].substr(0,decimal);
	}else{
		var c = decimal - str[1].length;
		//console.log(c);
		if( 1 == c )  var flo = str[1]+'0';
		if( 2 == c )  var flo = str[1]+'00';
		if( 3 == c )  var flo = str[1]+'000';
		if( 4 == c )  var flo = str[1]+'0000';
		//console.log(flo);
	}
	
	var n = str[0]+'.'+flo;
	//return parseFloat(n);
	return n;
}

//console.log(numberfomate(1.0,2));

function sell(){
	var cname=$("#cname").val();
	if($("#coinpriceout").val()==""){
		$("#trustmsgout").text("卖出价格不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
		return false;
	}
	if($("#numberout").val()==""){
		$("#trustmsgout").text("卖出数量不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
		return false;
	}
	if($("#pwdtradeout").val()==""){
		$("#trustmsgout").text("交易密码不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
		return false;
	}
	if(($("#coinpriceout").val())*($("#numberout").val())<1){
		$("#trustmsgout").text("交易额不能低于1元").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
		return false;
	}

	layer.confirm('确定卖出?', { 
		  btn: ['确定','取消'] //按钮
		  
		}, function(index){
			layer.close(index);
			$("body").append("<div id='loading' style='z-index:19891014; background-color:#000; opacity:0.3; filter:alpha(opacity=30);top: 0;left: 0;width: 100%;height: 100%;position: fixed;_position: absolute;text-align:center;'><img src='/public/home/images/loading.gif' style='margin-top:25%;' /></div>");
			$.ajax({
				type:"post",
				url:"{:U('Trade/sell')}",
				data:{sellprice:$("#coinpriceout").val(),sellnum:$("#numberout").val(),sellpwd:$("#pwdtradeout").val(),'currency_id':$("#currency_id").val()},
				async:true,
				success: function(d){
					$("#loading").remove();
					if(d.status!=1){
					$("#trustmsgout").text(d.info).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);	
					//加一个提示
					layer.msg(d.info);
					}else{
					layer.msg(d.info);
					//刷新页面
					setTimeout(window.location.reload(),2000);
					}
				}
			});
}, function(){
  layer.msg('已取消');
});
	
	<eq name="Think.session.is_phone" value="1" > <else />$('.layui-layer-dialog').css({position:'absolute',left:'45%',top:'55%'}) </eq>
	

}
</script>
<script>
function buy(){
	if($("#coinpricein").val()==""){
		$("#trustmsgin").text("买入价格不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
		return false;
	}
	if($("#numberin").val()==""){
		$("#trustmsgin").text("买入数量不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
		return false;
	}
	if($("#pwdtradein").val()==""){
		$("#trustmsgin").text("交易密码不能为空").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
		return false;
	}
	if(($("#coinpricein").val())*($("#numberin").val())<1){
		$("#trustmsgin").text("交易额不能低于1元").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);
		return false;
	}
	layer.confirm('确定买入?', {
	  btn: ['确定','取消'] //按钮
	}, function(index){
		layer.close(index);
		$("body").append("<div id='loading' style='z-index:19891014; background-color:#000; opacity:0.3; filter:alpha(opacity=30);top: 0;left: 0;width: 100%;height: 100%;position: fixed;_position: absolute;text-align:center;'><img src='/public/home/images/loading.gif' style='margin-top:25%;' /></div>");
		$.ajax({
			type:"post",
			url:"{:U('Trade/buy')}",
			data:{buyprice:$("#coinpricein").val(),buynum:$("#numberin").val(),buypwd:$("#pwdtradein").val(),currency_id:$("#currency_id").val()},
			async:true,
			success: function(d){
				$("#loading").remove();
				if(d.status!=1){
				$("#trustmsgin").text(d.info).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500);	
				//加一个提示
				layer.msg(d.info);
				}else{
				layer.msg(d.info);
				//刷新页面
				setTimeout(window.location.reload(),2000);
				}
			}
		});
	}, function(){
  layer.msg('已取消');
});
		<eq name="Think.session.is_phone" value="1" >  <else /> $('.layui-layer-dialog').css({position:'absolute',left:'3%',top:'55%'});</eq>
}
</script>
<script>
function badFloat(num, size){
    if(isNaN(num)) return true;
    num += '';
    if(-1 == num.indexOf('.')) return false;
    var f_arr = num.split('.');
    if(f_arr[1].length > size){
        return true;
    }
    return false;
}
//格式化小数
//@f float 传入小数: 123; 1.1234; 1.000001;
//@size int 保留位数
//@add bool 进位: 0舍 1进
function formatfloat(f, size, add){
    f = parseFloat(f);
    if(size == 0) conf = [1,1];
    if(size == 2) conf = [100,0.01];
    if(size == 3) conf = [1000,0.001];
    if(size == 4) conf = [10000,0.0001];
    if(size == 5) conf = [100000,0.00001];
    if(size == 6) conf = [1000000,0.000001];
    if(size == 7) conf = [10000000,0.0000001];
	if(size == 8) conf = [100000000,0.00000001];
    var ff = Math.floor(f * conf[0]) / conf[0];
    if(add && f > ff) ff += conf[1];
    return isNaN(ff)? 0: ff;
}
function vNum(o, len){
	if($("#coinpricein").val()!="" || $("#coinpricein").val()!="此出价为1个币的价格" && $("#numberin").val()!=""){

    if(badFloat(o.value, len))
		  o.value=formatfloat(o.value,len,0);

      var zuidakemai = $(".maxcoin").text();
       zuidakemai=formatfloat(zuidakemai,len,0);
      if($("#numberin").val() > zuidakemai){
        $("#numberin").val(zuidakemai);
      }
		  var fee2 = {$currency.currency_buy_fee} / 100;
		  var ci = $("#coinpricein").val()*$("#numberin").val();
		  var ct2 = ci ;//+ ci * fee2;


		$("#feebuy").text(Math.round(ci*fee2*10000)/10000);
		$("#coinin_sumprice").val(Math.round(ct2*10000)/10000);
	}
}

function vNum2(o, len){
	var zuida = $("#coinsale_max").text();
	//alert(zuida);
	
		//$("#numberout").val()=formatfloat($("#numberout").val(), len, 0);
		zuida=formatfloat(zuida, len, 4);
		//alert(o.value);
	
	if($("#numberout").val() > zuida){
		$("#numberout").val(zuida);
		//alert(234);
	}
	//alert(o.value);
	if($("#coinpriceout").val()!="" || $("#coinpriceout").val()!="此出价为1个币的价格" && $("#numberout").val()!=""){
	if(badFloat(o.value, len))
		o.value=formatfloat(o.value, len, 0);
	var nt = $("#coinpriceout").val()*$("#numberout").val();
	var fee = {$currency.currency_sell_fee} /100;
	var ct = nt;// - nt * fee;
  // alert(nt);
  // alert(fee);

	
	$("#fee").text(Math.round(nt*fee*10000)/10000);
	$("#coinout_sumprice").val(Math.round(ct*10000)/10000);
	}
	
}

function total_in(o,len){
	var max = $('#to_over').html();
	//alert(o.value);
	
		max = formatfloat(max, len, 4);
		o.value = formatfloat(o.value, len, 4);
		//alert(o.value);
		if(o.value > max) o.value = max;
		if($("#coinpricein").val()!="" || $("#coinpricein").val()!="此出价为1个币的价格" && $("#numberin").val()!=""){
		if(badFloat(o.value, len))
			o.value=formatfloat(o.value, len, 4);
			var nt = o.value/$("#coinpricein").val();
			var fee = {$currency.currency_sell_fee} /100;
			var ct = nt;// - nt * fee;
			
			$("#fee").text(Math.round(o.value*fee*10000)/10000);
			$("#numberin").val(Math.round(ct*10000)/10000);
		}
		
	
}
function total_out(o,len){
	var max = $('#from_over').html();
	//alert(o.value);
	
		max = formatfloat(max, len, 0);
		o.value = formatfloat(o.value, len, 0);
		//alert(o.value);
		if(o.value > max) o.value = max;
		if($("#coinpriceout").val()!="" || $("#coinpriceout").val()!="此出价为1个币的价格" && $("#numberout").val()!=""){
		if(badFloat(o.value, len))
			o.value=formatfloat(o.value, len, 0);
			var nt = o.value/$("#coinpriceout").val();
			var fee = {$currency.currency_sell_fee} /100;
			var ct = nt;// - nt * fee;
			
			$("#fee").text(Math.round(o.value*fee*10000)/10000);
			$("#numberout").val(Math.round(ct*10000)/10000);
		}
		
	
}



//5秒自动刷新挂单记录
/*setInterval(function(){
	$.post('/Home/Orders/getOrders',{"type":'sell',"currency_id":$("#currency_id").val()},function(data){
		$("#coinsalelist").empty();
		var length=parseInt(data.length)
		for(var i=0;i<data.length;i++){
			$("#coinsalelist").append(
				"<tr class='list_con2' onclick='getsell(this)' onmouseover='chufa1(this)' onmouseout='likai1(this)'><td class='sell left_sell' style='width:55px;'>卖("+(length-i)+")</td><td class='sell left_sell'  style='width:70px;cursor:pointer;'>¥"+numberfomate(data[i]['price'],{$currency.currency_digit_num})+"</td><td class='sell left_sell' >"+(numberfomate(((data[i]['num']-data[i]['trade_num'])),<eq name="currency.currency_name" value="比特币" > 3<else /> 2</eq>))+"</td><td class='sell left_sell'  style='width:80px;'>¥"+(numberfomate((data[i]['price']*(data[i]['num']-data[i]['trade_num'])),2))+"</td></tr>"
			);
		}
	});
		$.post('/Home/Orders/getOrders',{"type":'buy',"currency_id":$("#currency_id").val()},function(data){
		$("#coinbuylist").empty();
		var length=parseInt(data.length)
		for(var i=0;i<data.length;i++){
			$("#coinbuylist").append(
				"<tr class='list_con2' onclick='buynum(this)' onmouseover='chufa(this)' onmouseout='likai(this)'><td class='buy left_sell'  style='width:55px;'>买("+(parseInt(i)+1)+")</td><td  class='buy left_sell' style='width:70px;cursor:pointer;'>¥"+numberfomate(data[i]['price'],{$currency.currency_digit_num})+"</td><td  class='buy left_sell' onclick='buynum(this);'>"+(numberfomate(((data[i]['num']-data[i]['trade_num'])),<eq name="currency.currency_name" value="比特币" > 3<else /> 2</eq>))+"</td><td  class='buy left_sell' style='width:80px;'>¥"+(numberfomate((data[i]['price']*(data[i]['num']-data[i]['trade_num'])),2))+"</td></tr>"
			);
		}
	})		
},15000);
*/


</script>
<script>



function zuidakemai(){
	if($("#coinpricein").val()!="" && $("#coinpricein").val()!=0){
		var m = {$user_currency_money.currency_trade.num|default=0};
		var fee={$currency.currency_buy_fee}/100;
		m=m*(1-fee);
		var n = parseFloat($("#coinpricein").val());
		
		$(".maxcoin").text(Math.round(m/n*10000)/10000);
	}else{
		$(".maxcoin").text(0);
	}
}
</script>
<script>
	function cexiao(_this){
		layer.confirm('确定撤销委托？', {
	  btn: ['确定','取消'], //按钮
	  title: '撤销委托'
	}, function(){
	  $.post('{:U('Entrust/cancel')}',{status:-1,order_id:_this},function(data){
				   if(data['status'] == 1){
					   layer.msg(data['info']);
					   setTimeout(window.location.reload(),1000);
				   }else{
					   layer.msg(data['info']);
				   }
			})
	}, function(){
	  layer.msg('已取消');
	});

	}
	
	 function getsell(_this){
    var reg = /[a-zA-Z|¥|,]/g;
    var moneyStrmai= _this.children[1].innerText;
    var numberSremai= _this.children[2].innerText;
	var dnumberSremai = parseInt(numberSremai);
    var moneymai = moneyStrmai.replace(reg,"");
    var numbermai = dnumberSremai;
    coinbuymai = $("#coinbuy_aa").text();
    $("#coinpricein").val(moneymai);
    if(parseFloat(numbermai)>parseFloat(coinbuymai)){
      var num = moneymai*coinbuymai;
      $("#coinin_sumprice").val(num.toFixed(4));
      $("#numberin").val(coinbuymai);
      return false;
    }
    var num = moneymai*numbermai;
    $("#coinin_sumprice").val(num.toFixed(4));
    $("#numberin").val(numbermai);
    
    
  }
  
	
	function buynum(_this){
		var reg = /[a-zA-Z|¥|,]/g;
		var moneyStr= _this.children[1].innerText;
		var numberSre= _this.children[2].innerText;
		var money = moneyStr.replace(reg,"");
		var number = numberSre.replace(reg,"");
		var coinsale_max = $("#coinsale_max").text()
		$("#coinpriceout").val(money);
		if(parseFloat(number)>parseFloat(coinsale_max)){
			var num = money*coinsale_max;
			$("#coinout_sumprice").val(num.toFixed(4));
			$("#numberout").val(coinsale_max);
			return false;
		}
		var num = money*number;
		$("#coinout_sumprice").val(num.toFixed(4));
		$("#numberout").val(number);
	}

	function chufa(_this){
	 $(_this).css('background-color','#CCC');
	}
	function likai(_this){
	$(_this).css('background-color','#f6f6f6');
	}
	function chufa1(_this){
	 $(_this).css('background-color','#CCC');
	}
	function likai1(_this){
	$(_this).css('background-color','#f6f6f6');
	}

</script>
<include file="App/Home/View/Public/footer.html" />